// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/microsoft/vscode-cmake-tools>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
 * @import {Grammar} from '@wooorm/starry-night'
 */

/** @type {Grammar} */
const grammar = {
  extensions: ['.cmake', '.cmake.in'],
  names: ['cmake'],
  patterns: [
    {include: '#deprecatedKeywords'},
    {include: '#builtInCommands'},
    {include: '#systemVariables'},
    {include: '#changeBehaviorVariables'},
    {include: '#controlBuildVariables'},
    {include: '#provideInformationVariables'},
    {include: '#cacheEntryProperties'},
    {include: '#sourceFileProperties'},
    {include: '#testProperties'},
    {include: '#directoryProperties'},
    {include: '#globalProperties'},
    {include: '#targetProperties'},
    {include: '#commandProperties'},
    {include: '#variableReference'},
    {include: '#envVariableReference'},
    {include: '#cacheVariableReference'},
    {include: '#commandControl'},
    {include: '#conditionalControl'},
    {include: '#loopControl'},
    {include: '#returnControl'},
    {include: '#commandInvocationIdentifier'},
    {include: '#operators'},
    {include: '#boolean'},
    {include: '#bracketComment'},
    {include: '#bracketArgument'},
    {include: '#lineComment'},
    {include: '#quoted'},
    {include: '#string'},
    {include: '#generatorExpression'},
    {include: '#unquoted'}
  ],
  repository: {
    boolean: {
      match: '\\b(?i:FALSE|NO|OFF|ON|TRUE|YES)\\b',
      name: 'constant.language.boolean.cmake'
    },
    bracketArgument: {
      begin: '\\[(=*)\\[',
      beginCaptures: {0: {name: 'bracket-argument.begin.cmake'}},
      end: '\\](=*)\\]',
      endCaptures: {0: {name: 'bracket-argument.end.cmake'}},
      name: 'variable.parameter.cmake'
    },
    bracketComment: {
      begin: '#\\[(=*)\\[',
      beginCaptures: {0: {name: 'bracket-comment.begin.cmake'}},
      end: '\\](=*)\\]',
      endCaptures: {0: {name: 'bracket-comment.end.cmake'}},
      name: 'comment.line.number-sign.bracket.cmake'
    },
    builtInCommands: {
      match:
        '\\b(?i:add_compile_definitions|add_compile_options|add_custom_command|add_custom_target|add_definitions|add_dependencies|add_executable|add_library|add_link_options|add_subdirectory|add_test|aux_source_directory|block|build_command|build_name|cmake_file_api|cmake_host_system_information|cmake_language|cmake_minimum_required|cmake_parse_arguments|cmake_path|cmake_pkg_config|cmake_policy|configure_file|create_test_sourcelist|ctest_build|ctest_configure|ctest_coverage|ctest_empty_binary_directory|ctest_memcheck|ctest_read_custom_files|ctest_run_script|ctest_sleep|ctest_start|ctest_submit|ctest_test|ctest_update|ctest_upload|define_property|enable_language|enable_testing|endblock|execute_process|exec_program|export|export_library_dependencies|file|find_file|find_library|find_package|find_path|find_program|fltk_wrap_ui|get_cmake_property|get_directory_property|get_filename_component|get_property|get_source_file_property|get_target_property|get_test_property|include|include_directories|include_external_msproject|include_guard|include_regular_expression|install|install_files|install_programs|install_targets|link_directories|link_libraries|list|load_cache|load_command|make_directory|mark_as_advanced|math|message|option|output_required_files|project|qt_wrap_cpp|qt_wrap_ui|remove|remove_definitions|return|separate_arguments|set|set_directory_properties|set_property|set_source_files_properties|set_target_properties|set_tests_properties|site_name|source_group|string|subdirs|subdir_depends|target_compile_definitions|target_compile_features|target_compile_options|target_include_directories|target_link_directories|target_link_libraries|target_link_options|target_precompile_headers|target_sources|try_compile|try_run|unset|use_mangled_mesa|utility_source|variable_requires|variable_watch|write_file)\\b',
      name: 'support.function.cmake'
    },
    cacheEntryProperties: {
      match: '\\b(?i:ADVANCED|HELPSTRING|MODIFIED|STRINGS|TYPE|VALUE)\\b',
      name: 'support.type.cacheProperty.cmake'
    },
    cacheVariableReference: {
      match: '\\$CACHE\\{\\w+\\}',
      name: 'variable.other.cache.cmake'
    },
    changeBehaviorVariables: {
      match:
        '\\b(?i:BUILD_SHARED_LIBS|(CMAKE_)?(ABSOLUTE_DESTINATION_FILES|AUTOMOC_RELAXED_MODE|BACKWARDS_COMPATIBILITY|BUILD_TYPE|COLOR_MAKEFILE|CONFIGURATION_TYPES|DEBUG_TARGET_PROPERTIES|DISABLE_FIND_PACKAGE_\\w+|FIND_LIBRARY_PREFIXES|FIND_LIBRARY_SUFFIXES|IGNORE_PATH|INCLUDE_PATH|INSTALL_DEFAULT_COMPONENT_NAME|INSTALL_PREFIX|LIBRARY_PATH|MFC_FLAG|MODULE_PATH|NOT_USING_CONFIG_FLAGS|POLICY_DEFAULT_CMP\\w+|PREFIX_PATH|PROGRAM_PATH|SKIP_INSTALL_ALL_DEPENDENCY|SYSTEM_IGNORE_PATH|SYSTEM_INCLUDE_PATH|SYSTEM_LIBRARY_PATH|SYSTEM_PREFIX_PATH|SYSTEM_PROGRAM_PATH|USER_MAKE_RULES_OVERRIDE|WARN_ON_ABSOLUTE_INSTALL_DESTINATION))\\b',
      name: 'support.type.change.cmake'
    },
    commandControl: {
      match: '^\\s*\\b(?i:macro|endmacro|function|endfunction)\\b',
      name: 'keyword.control.command.cmake'
    },
    commandInvocationIdentifier: {
      match: '\\b(?i:\\w+)\\b\\s*(?=\\(|$)',
      name: 'entity.name.function.cmake'
    },
    commandProperties: {
      match:
        '\\b(?i:ALL|APPEND|BOOL|BUILD|BYPRODUCTS|CACHE|CAPTURE_CMAKE_ERROR|CMAKE_FIND_PACKAGE_NAME|CMAKE_FIND_ROOT_PATH_BOTH|CMAKE_FLAGS|COMMAND|COMMAND_EXPAND_LISTS|COMMENT|COMPILE_DEFINITIONS|COMPILE_OUTPUT_VARIABLE|COMPONENT|CONDITION|CONFIGURATION|CONFIGURATIONS|CONTENT|COPY_FILE|COPY_FILE_ERROR|COPYONLY|DEFECT_COUNT|DEPENDS|DEPFILE|DESTINATION|DIRECTORY|DOC|ENCODING|END|ESCAPE_QUOTES|EXCLUDE|EXCLUDE_FIXTURE|EXCLUDE_FIXTURE_CLEANUP|EXCLUDE_FIXTURE_SETUP|EXCLUDE_FROM_ALL|EXCLUDE_LABEL|EXPECTED_HASH|EXPECTED_MD|EXPR|FILEPATH|FILES|FILTER|FIND|FLAGS|GET|GLOBAL|HINTS|HTTPHEADER|IMPLICIT_DEPENDS|INACTIVITY_TIMEOUT|INCLUDE|INCLUDE_LABEL|INPUT|INPUT_FILE|INSERT|INSTALL|INTERNAL|LABELS|LENGTH|LENGTH_MAXIMUM|LENGTH_MINIMUM|LIMIT_COUNT|LIMIT_INPUT|LIMIT_OUTPUT|LINK_LIBRARIES|LOG|MAIN_DEPENDENCY|MD|NAMES|NETRC|NETRC_FILE|NEWLINE_CONSUME|NEWLINE_STYLE|NO_CMAKE_FIND_ROOT_PATH|NO_HEX_CONVERSION|NUMBER_ERRORS|NUMBER_WARNINGS|ONLY_CMAKE_FIND_ROOT_PATH|OPTIONAL|OPTIONS|OUTPUT|OUTPUT_QUIET|OUTPUT_VARIABLE|PACKAGE_FIND_NAME|PACKAGE_VERSION|PARALLEL_LEVEL|PARTS|PATH|PATH_SUFFIXES|PERMISSIONS|PRE_BUILD|PREFIX|PROJECT_NAME|QUIET|REGEX|REGULAR_EXPRESSION|REMOVE_AT|REMOVE_DUPLICATES|RENAME|RESULT_VARIABLE|RESULTS_VARIABLE|RETRY_COUNT|RETRY_DELAY|RETURN_VALUE|REVERSE|RUN_OUTPUT_VARIABLE|SCHEDULE_RANDOM|SHOW_PROGRESS|SORT|SOURCE|SOURCES|START|STATIC|STATUS|STOP_TIME|STRIDE|STRING|TARGET|TEST|TEST_LOAD|TIMEOUT|TLS_CAINFO|TLS_VERIFY|TREE|TYPE|USERPWD|USES_TERMINAL|VARIABLE|VERBATIM|WORKING_DIRECTORY)\\b',
      name: 'support.function.commandProperty.cmake'
    },
    conditionalControl: {
      match: '^\\s*\\b(?i:if|elseif|else|endif)\\b',
      name: 'keyword.control.conditional.cmake'
    },
    controlBuildVariables: {
      match:
        '\\b(?i:(CMAKE_)?(\\w+_POSTFIX|ARCHIVE_OUTPUT_DIRECTORY|AUTOMOC|AUTOMOC_MOC_OPTIONS|BUILD_WITH_INSTALL_RPATH|DEBUG_POSTFIX|EXE_LINKER_FLAGS|EXE_LINKER_FLAGS_\\w+|Fortran_FORMAT|Fortran_MODULE_DIRECTORY|GNUtoMS|INCLUDE_CURRENT_DIR|INCLUDE_CURRENT_DIR_IN_INTERFACE|INSTALL_NAME_DIR|INSTALL_RPATH|INSTALL_RPATH_USE_LINK_PATH|LIBRARY_OUTPUT_DIRECTORY|LIBRARY_PATH_FLAG|LINK_DEF_FILE_FLAG|LINK_DEPENDS_NO_SHARED|LINK_INTERFACE_LIBRARIES|LINK_LIBRARY_FILE_FLAG|LINK_LIBRARY_FLAG|MACOSX_BUNDLE|NO_BUILTIN_CHRPATH|PDB_OUTPUT_DIRECTORY|COMPILE_PDB_OUTPUT_DIRECTORY|POSITION_INDEPENDENT_CODE|RUNTIME_OUTPUT_DIRECTORY|SKIP_BUILD_RPATH|SKIP_INSTALL_RPATH|TRY_COMPILE_CONFIGURATION|USE_RELATIVE_PATHS|WIN32_EXECUTABLE)|EXECUTABLE_OUTPUT_PATH|LIBRARY_OUTPUT_PATH)\\b',
      name: 'support.type.build.cmake'
    },
    deprecatedKeywords: {
      match:
        '\\b(?i:ABSTRACT_FILES|BUILD_NAME|SOURCE_FILES|SOURCE_FILES_REMOVE|VTK_MAKE_INSTANTIATOR|VTK_WRAP_JAVA|VTK_WRAP_PYTHON|VTK_WRAP_TCL|WRAP_EXCLUDE_FILES)\\b',
      name: 'invalid.deprecated.cmake'
    },
    directoryProperties: {
      match:
        '\\b(?i:ADDITIONAL_MAKE_CLEAN_FILES|CACHE_VARIABLES|CLEAN_NO_CUSTOM|COMPILE_DEFINITIONS|COMPILE_DEFINITIONS_\\w+|DEFINITIONS|EXCLUDE_FROM_ALL|IMPLICIT_DEPENDS_INCLUDE_TRANSFORM|INCLUDE_DIRECTORIES|INCLUDE_REGULAR_EXPRESSION|INTERPROCEDURAL_OPTIMIZATION|INTERPROCEDURAL_OPTIMIZATION_\\w+|LINK_DIRECTORIES|LISTFILE_STACK|MACROS|PARENT_DIRECTORY|RULE_LAUNCH_COMPILE|RULE_LAUNCH_CUSTOM|RULE_LAUNCH_LINK|TEST_INCLUDE_FILE|VARIABLES|VS_GLOBAL_SECTION_POST_\\w+|VS_GLOBAL_SECTION_PRE_\\w+)\\b',
      name: 'support.type.directoryProperty.cmake'
    },
    envVariableReference: {
      match: '\\$ENV\\{\\w+\\}',
      name: 'variable.other.env.cmake'
    },
    escape: {match: '\\\\(.|$)', name: 'constant.character.escape.cmake'},
    generatorExpression: {
      begin: '\\$\\<',
      beginCaptures: {
        0: {name: 'keyword.other.generator-expression.begin.cmake'}
      },
      end: '[\\>\\s\\t\\r\\n]',
      endCaptures: {0: {name: 'keyword.other.generator-expression.end.cmake'}},
      name: 'keyword.other.generator-expression.cmake',
      patterns: [
        {include: '#generatorExpression'},
        {include: '#variableReference'},
        {include: '#envVariableReference'},
        {include: '#cacheVariableReference'}
      ]
    },
    globalProperties: {
      match:
        '\\b(?i:ALLOW_DUPLICATE_CUSTOM_TARGETS|DEBUG_CONFIGURATIONS|DISABLED_FEATURES|ENABLED_FEATURES|ENABLED_LANGUAGES|FIND_LIBRARY_USE_LIB64_PATHS|FIND_LIBRARY_USE_OPENBSD_VERSIONING|GLOBAL_DEPENDS_DEBUG_MODE|GLOBAL_DEPENDS_NO_CYCLES|IN_TRY_COMPILE|PACKAGES_FOUND|PACKAGES_NOT_FOUND|PREDEFINED_TARGETS_FOLDER|REPORT_UNDEFINED_PROPERTIES|RULE_LAUNCH_COMPILE|RULE_LAUNCH_CUSTOM|RULE_LAUNCH_LINK|RULE_MESSAGES|TARGET_ARCHIVES_MAY_BE_SHARED_LIBS|TARGET_SUPPORTS_SHARED_LIBS|USE_FOLDERS|__CMAKE_DELETE_CACHE_CHANGE_VARS_)\\b',
      name: 'support.type.globalProperty.cmake'
    },
    lineComment: {
      captures: {1: {name: 'comment.line.cmake'}},
      match: '#(.*)$',
      name: 'comment.line.number-sign.cmake'
    },
    loopControl: {
      match: '^\\s*\\b(?i:foreach|endforeach|while|endwhile|break|continue)\\b',
      name: 'keyword.control.loop.cmake'
    },
    operators: {
      match:
        '\\b(?i:ABSOLUTE|AND|COMMAND|DEFINED|DIRECTORY|EQUAL|EXISTS|GREATER|GREATER_EQUAL|IN_LIST|IS_ABSOLUTE|IS_DIRECTORY|IS_NEWER_THAN|IS_SYMLINK|LAST_EXT|LESS|LESS_EQUAL|MATCHES|NAME|NAME_WE|NAME_WLE|NOT|NOTFOUND|OR|PATH|PATHS|POLICY|PROGRAM|REALPATH|STREQUAL|STRGREATER|STRGREATER_EQUAL|STRING|STRLESS|STRLESS_EQUAL|TARGET|TEST|VERSION_EQUAL|VERSION_GREATER|VERSION_GREATER_EQUAL|VERSION_LESS)\\b',
      name: 'keyword.operator.cmake'
    },
    provideInformationVariables: {
      match:
        '\\b(?i:CMAKE_(AR|ARGC|ARGV0|BINARY_DIR|BUILD_TOOL|C_STANDARD|CXX_STANDARD|C_COMPILER|CXX_COMPILER|C_COMPILER_ID|CXX_COMPILER_ID|CACHEFILE_DIR|CACHE_MAJOR_VERSION|CACHE_MINOR_VERSION|CACHE_PATCH_VERSION|CFG_INTDIR|COMMAND|CROSSCOMPILING|CTEST_COMMAND|CURRENT_BINARY_DIR|CURRENT_LIST_DIR|CURRENT_LIST_FILE|CURRENT_LIST_LINE|CURRENT_SOURCE_DIR|DL_LIBS|EDIT_COMMAND|EXECUTABLE_SUFFIX|EXTRA_GENERATOR|EXTRA_SHARED_LIBRARY_SUFFIXES|GENERATOR|HOME_DIRECTORY|IMPORT_LIBRARY_PREFIX|IMPORT_LIBRARY_SUFFIX|LINK_LIBRARY_SUFFIX|MAJOR_VERSION|MAKE_PROGRAM|MINOR_VERSION|PARENT_LIST_FILE|PATCH_VERSION|PROJECT_NAME|RANLIB|ROOT|SCRIPT_MODE_FILE|SHARED_LIBRARY_PREFIX|SHARED_LIBRARY_SUFFIX|SHARED_MODULE_PREFIX|SHARED_MODULE_SUFFIX|SIZEOF_VOID_P|SKIP_RPATH|SOURCE_DIR|STANDARD_LIBRARIES|STATIC_LIBRARY_PREFIX|STATIC_LIBRARY_SUFFIX|TWEAK_VERSION|USING_VC_FREE_TOOLS|VERBOSE_MAKEFILE|VERSION)|PROJECT_BINARY_DIR|PROJECT_NAME|PROJECT_SOURCE_DIR|\\w+_BINARY_DIR|\\w+_SOURCE_DIR)\\b',
      name: 'support.type.provideInfo.cmake'
    },
    quoted: {
      begin: '"',
      end: '"',
      name: 'string.quoted.double-slash.cmake',
      patterns: [
        {include: '#escape'},
        {include: '#variableReference'},
        {include: '#envVariableReference'},
        {include: '#cacheVariableReference'}
      ]
    },
    returnControl: {
      match: '\\b(?i:return)\\b',
      name: 'keyword.control.return.cmake'
    },
    sourceFileProperties: {
      match:
        '\\b(?i:ABSTRACT|COMPILE_DEFINITIONS|COMPILE_DEFINITIONS_&lt;CONFIG&gt;|COMPILE_FLAGS|EXTERNAL_OBJECT|Fortran_FORMAT|GENERATED|HEADER_FILE_ONLY|KEEP_EXTENSION|LABELS|LANGUAGE|LOCATION|MACOSX_PACKAGE_LOCATION|OBJECT_DEPENDS|OBJECT_OUTPUTS|SYMBOLIC|WRAP_EXCLUDE)\\b',
      name: 'support.type.sourceFile.cmake'
    },
    systemVariables: {
      match:
        '\\b(?i:APPLE|BORLAND|(CMAKE_)?(CL_64|COMPILER_2005|HOST_APPLE|HOST_SYSTEM|HOST_SYSTEM_NAME|HOST_SYSTEM_PROCESSOR|HOST_SYSTEM_VERSION|HOST_UNIX|HOST_WIN32|LIBRARY_ARCHITECTURE|LIBRARY_ARCHITECTURE_REGEX|OBJECT_PATH_MAX|SYSTEM|SYSTEM_NAME|SYSTEM_PROCESSOR|SYSTEM_VERSION)|CYGWIN|MSVC|MSVC80|MSVC_IDE|MSVC_VERSION|UNIX|WIN32|XCODE_VERSION|MSVC60|MSVC70|MSVC90|MSVC71)\\b',
      name: 'support.type.system.cmake'
    },
    targetProperties: {
      match:
        '\\b(?i:\\w+_(OUTPUT_NAME|POSTFIX)|ARCHIVE_OUTPUT_(DIRECTORY(_\\w+)?|NAME(_\\w+)?)|AUTOMOC(_MOC_OPTIONS)?|BUILD_WITH_INSTALL_RPATH|BUNDLE|BUNDLE(_EXTENSION)?|COMPATIBLE_INTERFACE_BOOL|COMPATIBLE_INTERFACE_STRING|COMPILE_(DEFINITIONS(_\\w+)?|FLAGS)|DEBUG_POSTFIX|DEFINE_SYMBOL|ENABLE_EXPORTS|EXCLUDE_FROM_ALL|EchoString|FOLDER|FRAMEWORK|Fortran_(FORMAT|MODULE_DIRECTORY)|GENERATOR_FILE_NAME|GNUtoMS|HAS_CXX|IMPLICIT_DEPENDS_INCLUDE_TRANSFORM|IMPORTED|IMPORTED_(CONFIGURATIONS|IMPLIB(_\\w+)?|LINK_DEPENDENT_LIBRARIES(_\\w+)?|LINK_INTERFACE_LANGUAGES(_\\w+)?|LINK_INTERFACE_LIBRARIES(_\\w+)?|LINK_INTERFACE_MULTIPLICITY(_\\w+)?|LOCATION(_\\w+)?|NO_SONAME(_\\w+)?|SONAME(_\\w+)?)|IMPORT_PREFIX|IMPORT_SUFFIX|INSTALL_NAME_DIR|INSTALL_RPATH|INSTALL_RPATH_USE_LINK_PATH|INTERFACE|INTERFACE_COMPILE_DEFINITIONS|INTERFACE_INCLUDE_DIRECTORIES|INTERPROCEDURAL_OPTIMIZATION|INTERPROCEDURAL_OPTIMIZATION_\\w+|LABELS|LIBRARY_OUTPUT_DIRECTORY(_\\w+)?|LIBRARY_OUTPUT_NAME(_\\w+)?|LINKER_LANGUAGE|LINK_DEPENDS|LINK_FLAGS(_\\w+)?|LINK_INTERFACE_LIBRARIES(_\\w+)?|LINK_INTERFACE_MULTIPLICITY(_\\w+)?|LINK_LIBRARIES|LINK_SEARCH_END_STATIC|LINK_SEARCH_START_STATIC|LOCATION(_\\w+)?|MACOSX_BUNDLE|MACOSX_BUNDLE_INFO_PLIST|MACOSX_FRAMEWORK_INFO_PLIST|MAP_IMPORTED_CONFIG_\\w+|NO_SONAME|OSX_ARCHITECTURES(_\\w+)?|OUTPUT_NAME(_\\w+)?|PDB_NAME(_\\w+)?|POST_INSTALL_SCRIPT|PREFIX|PRE_INSTALL_SCRIPT|PRIVATE|PRIVATE_HEADER|PROJECT_LABEL|PUBLIC|PUBLIC_HEADER|RESOURCE|RULE_LAUNCH_(COMPILE|CUSTOM|LINK)|RUNTIME_OUTPUT_(DIRECTORY(_\\w+)?|NAME(_\\w+)?)|SKIP_BUILD_RPATH|SOURCES|SOVERSION|STATIC_LIBRARY_FLAGS(_\\w+)?|SUFFIX|TYPE|VERSION|VS_DOTNET_REFERENCES|VS_GLOBAL_(\\w+|KEYWORD|PROJECT_TYPES)|VS_KEYWORD|VS_SCC_(AUXPATH|LOCALPATH|PROJECTNAME|PROVIDER)|VS_WINRT_EXTENSIONS|VS_WINRT_REFERENCES|WIN32_EXECUTABLE|XCODE_ATTRIBUTE_\\w+)\\b',
      name: 'support.type.targetProperty.cmake'
    },
    testProperties: {
      match:
        '\\b(?i:DEPENDS|EXCLUDE_FROM_ALL|LABELS|NAME|PASS_REGULAR_EXPRESSION|RUN_SERIAL|RUN_TESTS|TIMEOUT)\\b',
      name: 'support.type.testProperty.cmake'
    },
    unquoted: {
      begin: '[^\\s()#"\\\\][^\\s()#"\\\\]*',
      end: '(?=\\s|\\(|\\)|#|"|\\|$)',
      name: 'string.unquoted.cmake',
      patterns: [
        {include: '#escape'},
        {include: '#variableReference'},
        {include: '#envVariableReference'},
        {include: '#cacheVariableReference'}
      ]
    },
    variableReference: {match: '\\$\\{\\w+\\}', name: 'variable.other.cmake'}
  },
  scopeName: 'source.cmake'
}

export default grammar
